package com.hongliang.netty01.slice;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.CompositeByteBuf;

/**
 * @author Hongliang Zhu
 * @create 2022-11-06 23:51
 */
public class TestComposite {
    public static void main(String[] args) {
        ByteBuf buffer1 = ByteBufAllocator.DEFAULT.buffer();
        buffer1.writeBytes(new byte[]{1, 2, 3, 4});

        ByteBuf buffer2 = ByteBufAllocator.DEFAULT.buffer();
        buffer2.writeBytes(new byte[]{5, 6, 7, 8});

        CompositeByteBuf byteBufs = ByteBufAllocator.DEFAULT.compositeBuffer();
        byteBufs.addComponents(true, buffer1, buffer2);

        System.out.println(ByteBufUtil.prettyHexDump(byteBufs));
    }
}
